package net.zjitc.servlet;

import net.zjitc.domain.Product;
import net.zjitc.service.ProductService;
import net.zjitc.service.impl.ProductServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @version 1.0
 * @autho 赵静静
 * @date 2018/10/18 9:07
 */
@WebServlet(name = "FindDetailServlet",urlPatterns = "/findDetailServlet")
public class FindDetailServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String pid = request.getParameter("pid");
        ProductService service = new ProductServiceImpl();
        Product product = service.findById(pid);
        request.setAttribute("p",product);
        request.getRequestDispatcher("/productDetail.jsp").forward(request,response);
    }
}
